//
//  UIImageView+WebImageVIew.m
//  3.28 练习
//
//  Created by Justsoso on 16/3/28.
//  Copyright © 2016年 Justsoso. All rights reserved.
//

#import "UIImageView+WebImageVIew.h"

@implementation UIImageView (WebImageVIew)

- (instancetype)initWithURL:(NSURL *)url
{
    self = [super init];
    if (self) {
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
            if (connectionError == nil)
            {
                self.image = [UIImage imageWithData:data];
            }
        }];
    }
    return self;
}

@end
